package com.survey.system.util;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.survey.system.domain.SurRegion;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

public class SurveyTreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private Long id;

    /**
     * 节点名称
     */
    private String label;

    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<SurveyTreeSelect> children;

    public SurveyTreeSelect() {

    }

    public SurveyTreeSelect(SurRegion region) {
        this.id = region.getRegionId();
        this.label = region.getRegionName();
        this.children = region.getChildren().stream().map(SurveyTreeSelect :: new).collect(Collectors.toList());
    }



    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<SurveyTreeSelect> getChildren() {
        return children;
    }

    public void setChildren(List<SurveyTreeSelect> children) {
        this.children = children;
    }
}
